
Page({

  /**
   * 页面的初始数据
   */
  data: {

    pinyinText: '',
    flag:false,
    buttonColor:'#808080',
    buttonColorlist:['#808080','#87cefa'],
    i:0,
    phone:'',
    verificationCode:'',
    nickName:"",
    password:'',
    repassword:'',
    role:'3'
  },


  repassword:function(e){
    this.setData({
      repassword:e.detail.value
    })
  },
// 以下是输入框信息
  password:function(e){
    this.setData({
      password:e.detail.value
    })
  },

  nickName:function(e){
    this.setData({
      nickName:e.detail.value
    })
  },
  // 以上是输入框信息
  back2:function(){
    wx.navigateBack({
      delta:1
    })
  },

  onClose2: function() {
  console.log("1111"),
  // 关闭页面或者返回上一页
  wx.switchTab({

    url: '/pages/my/my',
 
  }),
  console.log("333")
},


  check:function(){
    this.data.flag = ! this.data.flag;
    if(this.data.buttonColor == '#808080'){
      this.setData({
        buttonColor:'#87cefa'
      })  
    }else{
      this.setData({
        buttonColor:'#808080'
      })  
    }
  },

  toRegisterPage1(){
    console.log(123456);
    console.log(this.data.phone);
    console.log(456789);
    if(this.data.password == this.data.repassword){
      wx.request({
        url: 'http://localhost:8080/user/register',
        method:'POST',
        data:{
          username:this.data.nickName,
          password:this.data.password,
          nickname:this.data.nickName,
          email:this.data.verificationCode,
          phone:this.data.phone,
          role:this.data.role
        },
        header:{
          'Content-Type':'application/x-www-form-urlencoded'
        }
      })
      while(this.data.flag === true){
        console.log("1111")
        wx.navigateTo({
          url: '/pages/register2/register2',
        })
        return;
      }
    }
},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log("下边是电话吗");
    console.log(options);
    console.log(options.phoneNumber);
    console.log(options.verificationCode);
    
    this.setData({
      phone:options.phoneNumber,
      verificationCode:options.verificationCode + '@qq.com'
    });
    console.log(this.data.phone);
    console.log(this.data.verificationCode);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})